<?php
class home extends CI_controller{

	function __construct(){
		parent::__construct();

		$this->load->helper('maluku_helper');
		$this->load->library('maluku_lib');
		$this->load->model('hit_counter');

		//$flang = 'home';

		$this->lang->load('menu_top', $this->maluku_lib->language_name());
		
	}

	function index(){

		//menu
		$data['text_home'] = $this->lang->line('text_home');
		$data['text_corporate'] = $this->lang->line('text_corporate');
		$data['text_contact'] = $this->lang->line('text_contact');
		$data['text_site'] = $this->lang->line('text_site');

		$ip = $_SERVER['REMOTE_ADDR'];

		$date = date("Y-m-d H:i:s");
		$this->hit_counter->count($ip, $date);
		

		$data['contents'] = array('slide_home','news_home');

		$data['contents_sidebar'] = array('kurs_sidebar', 'tools_sidebar', 'polling_sidebar');

		foreach ($data['contents'] as $key => $val_contents) {
			include APPPATH."controllers/modul/$val_contents.php";

			${$val_contents} = new $val_contents();

			$data[$val_contents] = ${$val_contents}->index();
		}

		foreach ($data['contents_sidebar'] as $key => $val_contents_sidebar) {
			include APPPATH."controllers/modul/$val_contents_sidebar.php";

			${$val_contents_sidebar} = new $val_contents_sidebar();

			$data[$val_contents_sidebar] = ${$val_contents_sidebar}->index();
		}

		$data['head'] = 'layout/'. $this->maluku_lib->theme() .'/head';
		$data['menu'] = 'layout/'. $this->maluku_lib->theme() .'/menu';
		$data['footer'] = 'layout/'. $this->maluku_lib->theme() .'/footer';
		$this->load->view('layout/'. $this->maluku_lib->theme() .'/home', $data);	
	}

	function set_language(){
		
		$array = array(
			'language' =>  $this->uri->segment(3),
			'language_name' =>  $this->uri->segment(4),
		);
		$this->session->set_userdata($array);

		$base = $this->uri->segment(5);

		if($this->uri->segment(6)) $base .= "/".$this->uri->segment(6);
		if($this->uri->segment(7)) $base .= "/".$this->uri->segment(7);
		if($this->uri->segment(8)) $base .= "/".$this->uri->segment(8);
		if($this->uri->segment(9)) $base .= "/".$this->uri->segment(9);
		if($this->uri->segment(10)) $base .= "/".$this->uri->segment(10);

		redirect($base);
	}


}
?>